function [offset,ampl,freq,phase] = getSineComponent(data,dt)
    n = length(data);
    avg = mean(data);
    
    data = data - avg;
    hanndata = [(hanning(n)' .* data) zeros(1,2^nextpow2(n)-n)];
    npad = length(hanndata);
    fcmpl = fft(hanndata,npad);
    fabs = abs(fcmpl(1:npad/2+1));
    f = 1/2*linspace(0,1,npad/2+1);
    [m,pos] = max(fabs);
    freq = pos*2*pi / (npad*dt);
    
    flattopdata = [(flattopwin(n)' .* (data)) zeros(1,2^nextpow2(n)-n)];
    f2cmpl = fft(flattopdata,npad);
    f2abs = abs(f2cmpl(1:npad/2+1))*2/n;
    [m,pos] = max(f2abs);
    offsetft = fft([(flattopwin(n)' .* (data)) zeros(1,2^nextpow2(n)-n)]);
    offset = abs(offsetft(1))*2/n + avg;
    ampl = f2abs(pos);
    phase = angle(fcmpl(pos));    
end